This week we need to read data sheet and program my board to do something.
The ATtiny44 provides the following features: 4K byte of In-System Programmable Flash, 256 bytes EEPROM, 256 bytes SRAM, 12 general purpose I/O lines, 32 general purpose working registers, an 8-bit Timer/Counter with two PWM channels, a 16-bit timer/counter with two PWM channels, Internal and External Interrupts, a 8-channel 10-bit ADC, programmable gain stage (1x, 20x) for 12 differential ADC channel pairs, a programmable Watchdog Timer with internal oscillator, internal calibrated oscillator, and four software selectable power saving modes. Idle mode stops the CPU while allowing the SRAM, Timer/Counter, ADC, Analog Comparator, and Interrupt system to continue functioning. ADC Noise Reduction mode minimizes switching noise during ADC conversions by stopping the CPU and all I/O modules except the ADC. In Power-down mode registers keep their contents and all chip functions are disbaled until the next interrupt or hardware reset. In Standby mode, the crystal/resonator oscillator is running while the rest of the device is sleeping, allowing very fast start-up combined with low power consumption.
The device is manufactured using Atmel’s high density non-volatile memory technology. The onchip ISP Flash allows the Program memory to be re-programmed in-system through an SPI serial interface, by a conventional non-volatile memory programmer or by an on-chip boot code running on the AVR core.
The ATtiny 44 AVR is supported with a full suite of program and system development tools including: C Compilers, Macro Assemblers, Program Debugger/Simulators and Evaluation kits.
Features
•High Performance, Low Power AVR®
8-Bit Microcontroller
•Advanced RISC Architecture
– 120 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
•Non-volatile Program and Data Memories
– 2/4/8K Bytes of In-System Programmable Program Memory Flash
• Endurance: 10,000 Write/Erase Cycles
– 128/256/512 Bytes In-System Programmable EEPROM
• Endurance: 100,000 Write/Erase Cycles
– 128/256/512 Bytes Internal SRAM
– Programming Lock for Self-Programming
Flash Program and EEPROM Data Security
•
Peripheral Features
– 8-bit Timer/Counter with Prescaler and Two PWM Channels
– 8-bit High Speed Timer/Counter with Separate Prescaler
• 2 High Frequency PWM Outputs with Separate Output Compare Registers
• Programmable Dead Time Generator
– USI – Universal Serial Interface with Start Condition Detector
– 10-bit ADC
• 4 Single Ended Channels
• 2 Differential ADC Channel Pairs with Programmable Gain (1x, 20x)
• Temperature Measurement
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
•
Special Microcontroller Features
– debugWIRE On-chip Debug System
– In-System Programmable via SPI Port
– External and Internal Interrupt Sources
– Low Power Idle, ADC Noise Reduction, and Power-down Modes
– Enhanced Power-on Reset Circuit
– Programmable Brown-out Detection Circuit
– Internal Calibrated Oscillator
•
I/O and Packages
– Six Programmable I/O Lines
– 8-pin PDIP, 8-pin SOIC, 20-pad QFN/ML
F, and 8-pin TSSOP (only ATtiny45/V)
•
Operating Voltage
– 1.8 - 5.5V for ATtiny25V/45V/85V
– 2.7 - 5.5V for ATtiny25/45/
We need to read ATtiny 44 datasheet, there are 200 over pages and most of them i not really understand. However, when you want to know PIN configurations, AVR Status Register etc, you can find in the datasheet.
After going through data sheet I went through the Arduino pin configuration of Attiny.So that I can easily program with out the confusion.
Fuse Calculator is useful when you dont use arduino as isp. However, there are some problem with my Fab ISP, so I have to use ardunio to test out my ATtiny44.
Firstly, I set my arduino as ISP and use sample program blink to test my hello board. I need to get the library for ATtiny at board manager .
Open ArduinoISP sketch from File >> Examples >> ArduionISP Select Board >> Arduino Uno
Select Port that correspond to your port, in my case it's COM7
Upload the ArduinoISP sketch to the Arduino Uno
Connect the hello board to the Arduino Uno in the following order:
VCC: 5V
GND: GND
RST: Pin 10
MOSI: Pin 11
MISO: Pin 12
SCK: Pin 13
Then go to Tools >> Board >> Attiny
In my board, I cross checked the VCC and Rest pind of ATTiny controller and then I connected USB tiny programmer.
Then Using arduino IDE I programmed my board such away that button is assigned to LED and LED will glow once the button is pressed.
CODE
const int buttonPin = 2;
// the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(3, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(2, INPUT);
//Enabling pull up
pinMode(3, INPUT);
digitalWrite(3, HIGH);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(3, HIGH);
} else {
// turn LED off:
digitalWrite(3, LOW);
}
}